unit Clock;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, StdCtrls, Menus, Buttons, FormImage;

type
  TFormClock = class(TForm)
    TimerTime: TTimer;
    EditCommand: TEdit;
    ImageClick: TImage;
    LabelTime: TLabel;
    LabelDate: TLabel;
    fcImageForm1: TFormImage;
    fcImageBtn1: TBitBtn;
    procedure TimerTimeTimer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ImageClickDblClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure EditCommandKeyPress(Sender: TObject; var Key: Char);
    procedure fcImageBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    normalclose: boolean;
  end;

var
  FormClock: TFormClock;

implementation

uses Main;

{$R *.DFM}

procedure TFormClock.FormCreate(Sender: TObject);
begin
  normalclose:=false;
  width:=150;
  height:=75;
  TimerTimeTimer(Sender);
end;

procedure TFormClock.TimerTimeTimer(Sender: TObject);
begin
  LabelDate.caption:=FormatDateTime('ddd mmm d, yyyy',date);
  LabelTime.caption:=FormatDateTime('h:mm:ss am/pm',time);
end;

procedure TFormClock.ImageClickDblClick(Sender: TObject);
begin
  normalclose:=true;
  close;
end;

procedure TFormClock.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if not normalclose then begin
    if messagedlg('Are you sure you want to shut down the clock?',
      mtconfirmation,[mbyes,mbno],0) = mrno then abort;
    FormMain.PanicClose;
  end;
end;

procedure TFormClock.EditCommandKeyPress(Sender: TObject; var Key: Char);
begin
  if key = #13 then begin
    FormMain.EditSend.text:=EditCommand.text;
    FormMain.EditSendKeyPress(Sender,key);
    EditCommand.text:=FormMain.EditSend.text;
  end;
end;

procedure TFormClock.fcImageBtn1Click(Sender: TObject);
begin
  close;
end;

end.
